﻿using Equipment.API.Application.Service.DetectionmethodService;
using Equipment.API.DTOs.RequestDto.DefectlocationListRequest;
using Equipment.API.DTOs.ResponseDto.DefectlocationResponse;
using Equipment.Domain.Detectionmethod;
using Equipment.Errorcode;
using Equipment.Errorcode.ErrorCode;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Equipment.API.Controllers
{
    /// <summary>
    /// 缺陷位置控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DefectlocationController : ControllerBase
    {
        private readonly DefectlocationService _defectlocationService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="defectlocationService"></param>
        public DefectlocationController(DefectlocationService defectlocationService)
        {
            _defectlocationService = defectlocationService;
        }
        /// <summary>
        /// 缺陷位置信息下拉框
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetDefectlocationDropdown()
        {
            return await _defectlocationService.GetDefectlocationDropdown();
        }
        /// <summary>
        /// 新增缺陷位置信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> AddDefectlocation(AddDefectlocationResponseDto param)
        {
            return await _defectlocationService.AddDefectlocation(param);
        }

        /// <summary>
        /// 获取缺陷位置信息列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetDefectlocationList([FromQuery]int pageNumber = 1, int pageSize = 2)
        {
            return await _defectlocationService.GetDefectlocationList(pageNumber, pageSize);
        }

        /// <summary>
        /// 修改缺陷位置信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateDefectlocation(UpdateDefectlocationRequestDto param)
        {
            return await _defectlocationService.UpdateDefectlocation(param);
        }

        /// <summary>
        /// 删除缺陷位置信息
        /// </summary>
        /// <param name="Defectlocationid"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DeleteDefectlocation(int Defectlocationid)
        {
            return await _defectlocationService.DeleteDefectlocation(Defectlocationid);
        }

    }
}
